package com.example4.test6;/**
 *@Auther: shiquan
 *@Date: 2024/10/16 - 10 - 16 -12:56
 */
public class PhoneTest {
    public static void main(String[] args) {
        Phone[] arr = new Phone[3];

        Phone p1 = new Phone("小米", 1999, "白色");
        Phone p2 = new Phone("红米", 2999, "红色");
        Phone p3 = new Phone("华为", 4999, "粉色");

        arr[0]=p1;
        arr[1]=p2;
        arr[2]=p3;

        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            Phone phone=arr[i]; //数组里面每一个手机对象
            sum = phone.getPrice()+sum;
        }
        //求平均值
        int avg = sum/3;
        System.out.println(avg);

    }
}
